package com.zhaoyizhe.demo.mapper;

import com.zhaoyizhe.demo.model.BookInfo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface BookInfoMapper {

    @Insert("insert into book_info (book_name,author,`count`,price,publish,`status`) values " +
            "(#{bookName},#{author},#{count},#{price},#{publish},#{status})")
    Integer addBook(BookInfo bookInfo);

    @Select("select count(*) from book_info where `status` != 0 ")
    Integer getAllBookSize();

    @Select("select * from book_info where `status` != 0 limit #{offset},#{pageSize}")
    List<BookInfo> getPageBooks(int offset, Integer pageSize);

    @Select("select * from book_info where id = #{id}")
    BookInfo updateGetBookInfo(Integer id);

    Integer updateBookInfo(BookInfo bookInfo);

    Integer batchDeleteBooks(List<Integer> bookIds);
}
